﻿using RepositoryAndEf.Domain;
using System.Data.Entity.ModelConfiguration;

namespace RepositoryAndEf.Data.Mapping
{
    public class ShoppingCartMap : EntityTypeConfiguration<ShoppingCart>
    {
        public ShoppingCartMap()
        {
            ToTable("ShoppingCarts")
               .HasKey(c => c.Id)
               .HasMany<ShoppingCartItem>(c => c.Items).WithRequired();

            HasRequired(s => s.Customer).WithMany().HasForeignKey(s => s.CustomerId);
        }
    }
}
